//package com.ai.module.order.util;
//
//
//import com.ai.module.order.constant.WeChatPayUrl;
//import com.alibaba.fastjson2.JSONObject;
//import com.wechat.pay.contrib.apache.httpclient.WechatPayHttpClientBuilder;
//import com.wechat.pay.contrib.apache.httpclient.util.PemUtil;
//import org.apache.http.HttpEntity;
//import org.apache.http.HttpResponse;
//import org.apache.http.client.methods.HttpPost;
//import org.apache.http.entity.StringEntity;
//import org.apache.http.impl.client.CloseableHttpClient;
//import org.apache.http.util.EntityUtils;
//import org.springframework.context.annotation.Bean;
//import org.springframework.stereotype.Component;
//
//import java.io.ByteArrayInputStream;
//import java.nio.charset.StandardCharsets;
//import java.security.PrivateKey;
//import java.security.cert.X509Certificate;
//import java.util.ArrayList;
//import java.util.List;
//
//@Component
//public class WePayUtil {
//
//
//    private static final String APPLICATION_JSON = "application/json";
//    private static final String mchId = WeChatPayUrl.MCH_ID;
//            //"商户号"; // 商户号
//    private static final String mchSerialNo = WeChatPayUrl.MCH_SERIAL_NO;
//            //"第一步申请完证书后，在API证书哪里点击管理证书就能看到"; // 商户证书序列号
//
//    // 你的商户私钥
//    private static final String privateKey =WeChatPayUrl.API_CLIENT_KEY;
//            //"第一步中生成的apiclient_key.pem内容";
//    // 你的微信支付平台证书
//    private static final String certificate = WeChatPayUrl.WX_CERT;
//            //= "第二步中生成的wechatpay_267E31F15F097EC70CC6B6C56919D2605966123D.pem内容";
//    private CloseableHttpClient httpClient;
//
//    @Bean
//    public void setup() {
//        X509Certificate wechatPayCertificate = PemUtil.loadCertificate(
//                new ByteArrayInputStream(certificate.getBytes(StandardCharsets.UTF_8)));
//
//        List<X509Certificate> listCertificates = new ArrayList<>();
//        listCertificates.add(wechatPayCertificate);
//
//        WechatPayHttpClientBuilder builder = WechatPayHttpClientBuilder.create()
//                .withMerchant(mchId, mchSerialNo, PemUtil.loadPrivateKey(privateKey))
//                .withWechatPay(listCertificates);
//        httpClient = builder.build();
//    }
//
//
//}